package com.gitee.qdbp.jdbc.plugins.impl;

import com.gitee.qdbp.jdbc.exception.UnsupportedFieldException;
import com.gitee.qdbp.jdbc.model.FieldScene;
import com.gitee.qdbp.jdbc.plugins.ColumnNameResolver;
import com.gitee.qdbp.jdbc.sql.fragment.QueryFragmentHelper;

/**
 * 字段名转列名实现类
 *
 * @author zhaohuihua
 * @version 20210510
 */
public class ColumnNameHelper implements ColumnNameResolver {

    private final QueryFragmentHelper helper;
    private final FieldScene scene;

    public ColumnNameHelper(QueryFragmentHelper helper, FieldScene scene) {
        this.helper = helper;
        this.scene = scene;
    }

    @Override
    public String getColumnName(String fieldName) throws UnsupportedFieldException {
        if (fieldName == null) {
            return null;
        }
        return helper.getColumnName(scene, fieldName, true);
    }
}
